
next  = function()
{
	console.log('111111 next')
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var pageIndex = parseInt(document.getElementById("pageIndex").innerHTML)
	pageIndex = pageIndex + 1

	if (pageIndex>parseInt(document.getElementById("pageNum").innerHTML))
		alert('已经是最后一页了')
	else
  		window.location.href='/offerList/?advertiser_id=' + advertiser_id + '&pageIndex=' + pageIndex  + '&isAll=' + true

}

previous  = function()
{
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var pageIndex = parseInt(document.getElementById("pageIndex").innerHTML)
	pageIndex = pageIndex - 1
	
	if (pageIndex==0)
		alert('已经是第一页了')
	else
  		window.location.href='/offerList/?advertiser_id=' + advertiser_id + '&pageIndex=' + pageIndex  + '&isAll=' + true

}


goto  = function()
{
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var pageIndex = parseInt(document.getElementById("gotoPage").value)
	
	if (pageIndex>0&&pageIndex<=parseInt(document.getElementById("pageNum").innerHTML))
		window.location.href='/offerList/?advertiser_id=' + advertiser_id + '&pageIndex=' + pageIndex + '&isAll=' + true
	else
  		alert('错误的参数')

}

refreshOfferList = function()
{
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var pageIndex = parseInt(document.getElementById("pageIndex").innerHTML)
	window.location.href='/offerList/?advertiser_id=' + advertiser_id + '&pageIndex=' + pageIndex + '&isAll=' + true
}


addToSql = function()
{	
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var showNumsPerPage = document.getElementById("showNumsPerPage").innerHTML
	var pageIndex = parseInt(document.getElementById("pageIndex").innerHTML)
	var checkbox = document.getElementById("isAll")

	if(checkbox.checked)
	{	
		window.location.href='/addToSql/?advertiser_id=' + advertiser_id + '&isAll=' + true 
		alert('已录入数据库,刷新界面重新拉取....')
		return 
	}


	var body = '<html>'+
	'<body>'+
    '<form action="/addToSql" method=post name=formx1 style="display:none">' + 
    '<input type=hidden name="advertiser_id" value=' +  advertiser_id +  ' />'
	var start = showNumsPerPage * (pageIndex - 1)
	for(var i=start;;i++)
	{	
		var checkbox = document.getElementById(i)
		if(!checkbox)
			break
		if(checkbox.checked)
			body = body + '<input type=hidden name=' + i + ' value=' +  checkbox.value +  ' />'
	}

	body = body + '</form>'+  
    '</body>'+
    '</html>'
    document.write(body)
    document.formx1.submit()

   	alert('已录入数据库,刷新界面重新拉取....')

}

filterAppid = function()
{	
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var showNumsPerPage = document.getElementById("showNumsPerPage").innerHTML
	var pageIndex = parseInt(document.getElementById("pageIndex").innerHTML)
	var checkbox = document.getElementById("isAll")

	if(checkbox.checked)
	{	
		window.location.href='/offerList/?filterAppid=true&advertiser_id=' + advertiser_id + '&pageIndex=' + pageIndex + '&isAll=' + true
		return 
	}

	var body = '<html>'+
	'<body>'+
    '<form action="/offerList/?filterAppid=true" method=post name=formx1 style="display:none">' + 
    '<input type=hidden name="advertiser_id" value=' +  advertiser_id +  ' />'
	var start = showNumsPerPage * (pageIndex - 1)
	for(var i=start;;i++)
	{	
		var checkbox = document.getElementById(i)
		if(!checkbox)
			break
		if(checkbox.checked)
			body = body + '<input type=hidden name=' + i + ' value=' +  checkbox.value +  ' />'
	}

	body = body + '</form>'+  
    '</body>'+
    '</html>'
    document.write(body)
    document.formx1.submit()
}

icon_linkUpdate = function()
{
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var showNumsPerPage = document.getElementById("showNumsPerPage").innerHTML
	var pageIndex = parseInt(document.getElementById("pageIndex").innerHTML)
	var checkbox = document.getElementById("isAll")

	if(checkbox.checked)
	{	
		alert('正在更新icon_link,点击刷新获取进度....')
		window.location.href='/offerList/?icon_linkUpdate=true&advertiser_id=' + advertiser_id + '&pageIndex=' + pageIndex + '&isAll=' + true
		return 
	}

	var body = '<html>'+
	'<body>'+
    '<form action="/offerList/?icon_linkUpdate=true" method=post name=formx1 style="display:none">' + 
    '<input type=hidden name="advertiser_id" value=' +  advertiser_id +  ' />'+
    '<input type=hidden name="pageIndex" value=' +  pageIndex +  ' />'

	var start = showNumsPerPage * (pageIndex - 1)
	for(var i=start;;i++)
	{	
		var checkbox = document.getElementById(i)
		if(!checkbox)
			break
		if(checkbox.checked)
			body = body + '<input type=hidden name=' + i + ' value=' +  checkbox.value +  ' />'
	}

	body = body + '</form>'+  
    '</body>'+
    '</html>'
    document.write(body)
    document.formx1.submit()

	alert('正在更新icon_link,点击刷新获取进度....')
}

loadCreative = function()
{
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var showNumsPerPage = document.getElementById("showNumsPerPage").innerHTML
	var pageIndex = parseInt(document.getElementById("pageIndex").innerHTML)
	var checkbox = document.getElementById("isAll")

	if(checkbox.checked)
	{	
		alert('开始下载creative,点击刷新获取进度....')
		window.location.href='/offerList/?loadCreative=true&advertiser_id=' + advertiser_id + '&pageIndex=' + pageIndex + '&isAll=' + true
		return 
	}

	var body = '<html>'+
	'<body>'+
    '<form action="/offerList/?loadCreative=true" method=post name=formx1 style="display:none">' + 
    '<input type=hidden name="advertiser_id" value=' +  advertiser_id +  ' />'+
    '<input type=hidden name="pageIndex" value=' +  pageIndex +  ' />'

	var start = showNumsPerPage * (pageIndex - 1)
	for(var i=start;;i++)
	{	
		var checkbox = document.getElementById(i)
		if(!checkbox)
			break
		if(checkbox.checked)
			body = body + '<input type=hidden name=' + i + ' value=' +  checkbox.value +  ' />'
	}

	body = body + '</form>'+  
    '</body>'+
    '</html>'
    document.write(body)
    document.formx1.submit()

	alert('开始下载creative,点击刷新获取进度....')

}

creative_LinkUpdate = function()
{
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var showNumsPerPage = document.getElementById("showNumsPerPage").innerHTML
	var pageIndex = parseInt(document.getElementById("pageIndex").innerHTML)
	var checkbox = document.getElementById("isAll")

	if(checkbox.checked)
	{	
		alert('正在更新creative_link,点击刷新获取进度....')
		window.location.href='/offerList/?creative_LinkUpdate=true&advertiser_id=' + advertiser_id + '&pageIndex=' + pageIndex + '&isAll=' + true
		return 
	}

	var body = '<html>'+
	'<body>'+
    '<form action="/offerList/?creative_LinkUpdate=true" method=post name=formx1 style="display:none">' + 
    '<input type=hidden name="advertiser_id" value=' +  advertiser_id +  ' />'+
    '<input type=hidden name="pageIndex" value=' +  pageIndex +  ' />'

	var start = showNumsPerPage * (pageIndex - 1)
	for(var i=start;;i++)
	{	
		var checkbox = document.getElementById(i)
		if(!checkbox)
			break
		if(checkbox.checked)
			body = body + '<input type=hidden name=' + i + ' value=' +  checkbox.value +  ' />'
	}

	body = body + '</form>'+  
    '</body>'+
    '</html>'
    document.write(body)
    document.formx1.submit()

	alert('正在更新creative_link,点击刷新获取进度....')
}

chooseAllOnCurrentPage = function()
{	
	var advertiser_id = document.getElementById("advertiser_id").innerHTML
	var showNumsPerPage = document.getElementById("showNumsPerPage").innerHTML
	var pageIndex = parseInt(document.getElementById("pageIndex").innerHTML)

	var start = showNumsPerPage * (pageIndex - 1)
	for(var i=start;;i++)
	{	
		var checkbox = document.getElementById(i)
		if(!checkbox)
			break
		checkbox.checked = true
	}

	//window.location.href='/offerList/?advertiser_id=' + advertiser_id + '&pageIndex=' + pageIndex 
}


